package com.taotao.service;

import lombok.Getter;
import lombok.Setter;

/**
 * <p>
 * 业务异常,用于service给上层返回业务上错误信息
 * </p>
 *
 * @author fanbeibei
 * @version V1.0
 * @since 2019/6/12 9:44
 */
@Getter
@Setter
public class BusinessException extends RuntimeException {

    private int code;
    private Object data;

    public BusinessException(String msg) {
        super(msg);
        this.code = RespData.FAIL_CODE;
    }

    public BusinessException(int code, String msg) {
        super(msg);
        this.code = code;
    }

    public BusinessException(int code, String msg, Object data) {
        super(msg);
        this.data = data;
        this.code = code;
    }

    protected BusinessException(int code, Object data, Throwable cause) {
        super(cause);
        this.code = code;
        this.data = data;
    }

    protected BusinessException(int code, Throwable cause) {
        super(cause);
        this.code = code;
    }

    protected BusinessException(Throwable cause) {
        super(cause);
        this.code = RespData.FAIL_CODE;
    }


    @Override
    public synchronized Throwable fillInStackTrace() {
        return this;
    }
}
